//
//  main.m
//  WeatherDesktop
//
//  Created by Justin Dell on 11/07/08.
//  Copyright  2008. All rights reserved.
//

#import <Cocoa/Cocoa.h>
#import <stdio.h>
#import <sys/types.h>
#import <unistd.h>
#import "WallpaperModifier.h"

int main(int argc, char *argv[])
{
    NSLog(@"Beginning weather desktop engine\n");
    if (argc != 3) { 
        NSLog(@"Invalid number of arguments\n"); 
        return -1; 
    }
    
    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
    NSString* zip = [NSString stringWithUTF8String:argv[1]];
    NSString* refresh = [NSString stringWithUTF8String:argv[2]];
    WallpaperModifier* wp = [[WallpaperModifier alloc] initWithZip:zip];
    while(1) { 
        if ([wp setWallpaper:nil] != 0) {
            NSLog(@"Error setting wallpaper\n");
        }
        NSLog(@"Wallpaper set\n");
        sleep([refresh integerValue] * 60);
        NSLog(@"Done sleeping\n");
    }

    [pool release];
}